<?php


namespace App\Logic;


use App\common;
use App\Models\JointTenancy;
use App\Models\News;

class JointTenancyLogic
{
    /**
     * 合租信息展示列表
     */
    public static function Secondary(){
        return JointTenancy::list();
    }
    /**
     * 合租详情
     */
    public static function SecondaryDetails($fangID){
        if(empty($fangID))throw new \Exception('未接收到想要查看的合租信息');
        $executeDetail=JointTenancy::detail('id',$fangID);
        return $executeDetail;
    }
    /**
     * 资讯信息添加
     */
    public static function SecondaryAdd($request){
        $validated = $request->validate([
            'title' => 'required',
            'content' => 'required',
            'author' => 'required',
            'publish_time' => 'required',
            'update_time' => 'required',
            'views_count' => 'required',
            'likes_count' => 'required',
        ],[
            'title.required'=>'不能为空',
            'content.required'=>'不能为空',
            'author.required'=>'不能为空',
            'publish_time.required'=>'不能为空',
            'update_time.required'=>'不能为空',
            'views_count.required'=>'不能为空',
            'likes_count.required'=>'不能为空',
        ]);
        $SecondaryModel=JointTenancy::create($validated);
        return $SecondaryModel;
    }
}
